<!-- eslint-disable max-len -->
<template>
  <a-form-model
    class="detailPaddingPage"
    style="display: flex; flex-direction: column"
    :layout="formLayout"
    :colon="false">
    <!-- 申请信息 -->
    <a-form-model-item label="申请信息" class="customFormModelItem2"> </a-form-model-item>
    <a-form-model-item>
      <a-row >
        <!-- 模板类型 -->
        <a-col :md="8" :sm="24">
          <a-row>
            <a-col :md="9" :sm="24">
              <a-form-model-item class="deepClass">
                {{ $t('templateType') }}
              </a-form-model-item>
            </a-col>
            <a-col :md="12" :sm="24">
              <a-form-model-item>
                <table-ellipsis :text="formData.testCarApplyFormVO.templateType || '-'"></table-ellipsis>
              </a-form-model-item></a-col>
          </a-row>
        </a-col>
        <!-- 申请类型 -->
        <a-col :md="8" :sm="24">
          <a-row>
            <a-col :md="9" :sm="24">
              <a-form-model-item class="deepClass">
                申请类型
              </a-form-model-item>
            </a-col>
            <a-col :md="12" :sm="24">
              <a-form-model-item>
                <table-ellipsis :text="formData.testCarApplyFormVO.applyType || '-'"></table-ellipsis>
              </a-form-model-item></a-col>
          </a-row>
        </a-col>
        <!-- 备注 -->
        <!-- <a-col :md="8" :sm="24">
          <a-row>
            <a-col :md="9" :sm="24">
              <a-form-model-item class="deepClass">
                备注
              </a-form-model-item>
            </a-col>
            <a-col :md="12" :sm="24">
              <a-form-model-item>
                <table-ellipsis :text="formData.testCarApplyFormVO.remark || '-'"></table-ellipsis>
              </a-form-model-item></a-col>
          </a-row>
        </a-col> -->
        <!-- 申请人 -->
        <a-col :md="8" :sm="24">
          <a-row>
            <a-col :md="9" :sm="24">
              <a-form-model-item class="deepClass">
                申请人
              </a-form-model-item>
            </a-col>
            <a-col :md="12" :sm="24">
              <a-form-model-item>
                <table-ellipsis :text="formData.testCarApplyFormVO.applyer || '-'"></table-ellipsis>
              </a-form-model-item></a-col>
          </a-row>
        </a-col>

        <!-- 申请时间 -->
        <a-col :md="8" :sm="24">
          <a-row>
            <a-col :md="9" :sm="24">
              <a-form-model-item class="deepClass">
                申请时间
              </a-form-model-item>
            </a-col>
            <a-col :md="12" :sm="24">
              <a-form-model-item>
                <table-ellipsis :text="formData.testCarApplyFormVO.applyTime || '-'"></table-ellipsis>
              </a-form-model-item></a-col>
          </a-row>
        </a-col>
      </a-row>
    </a-form-model-item>
    <a-form-model-item label="车型信息" class="customFormModelItem2"> </a-form-model-item>
        <a-form-model-item>
           <a-row >
             <!-- 车型名称 -->
             <a-col :md="8" :sm="8">
              <a-row>
                <a-col :md="9" :sm="24">
                  <a-form-model-item class="deepClass">
                    车型名称
                  </a-form-model-item>
                </a-col>
                <a-col :md="12" :sm="24">
                  <a-form-model-item>
                    <table-ellipsis :text="formData.testCarApplyFormVO.modelName || '-'"></table-ellipsis>
                  </a-form-model-item>
                </a-col>
               </a-row>
              </a-col>
              <!-- 车型代码 -->
               <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      车型代码
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.modelCode || '-'">
                      </table-ellipsis>
                    </a-form-model-item>
                  </a-col>
                 </a-row>
                </a-col>
                <!-- 品牌 -->
                   <a-col :md="8" :sm="24">
                     <a-row>
                       <a-col :md="9" :sm="24">
                         <a-form-model-item class="deepClass">
                           品牌
                         </a-form-model-item>
                       </a-col>
                       <a-col :md="12" :sm="24">
                         <a-form-model-item>
                          <table-ellipsis :text="$store.getters.getDictCodeObj('companyDictCode')[formData.testCarApplyFormVO.company] || '-'"></table-ellipsis>
                         </a-form-model-item>
                        </a-col>
                     </a-row>
                   </a-col>
           </a-row>

           <a-row >
                <!-- 车系 -->
                <a-col :md="8" :sm="24">
                  <a-row>
                    <a-col :md="9" :sm="24">
                      <a-form-model-item class="deepClass">
                        车系
                      </a-form-model-item>
                    </a-col>
                    <a-col :md="12" :sm="24">
                      <a-form-model-item>
                        <table-ellipsis :text="formData.testCarApplyFormVO.brandName || '-'"></table-ellipsis>
                      </a-form-model-item>
                      </a-col>
                  </a-row>
                </a-col>
                <!-- 款型名称 -->
                <a-col :md="8" :sm="8">
                 <a-row>
                   <a-col :md="9" :sm="24">
                     <a-form-model-item class="deepClass">
                       款型名称
                     </a-form-model-item>
                   </a-col>
                   <a-col :md="12" :sm="24">
                     <a-form-model-item>
                       <table-ellipsis :text="formData.testCarApplyFormVO.modelStyleName || '-'"></table-ellipsis>
                     </a-form-model-item>
                   </a-col>
                 </a-row>
                </a-col>
                <!-- 销售区域 -->
                <a-col :md="8" :sm="8">
                  <a-row>
                    <a-col :md="9" :sm="24">
                      <a-form-model-item class="deepClass">
                        销售区域
                      </a-form-model-item>
                    </a-col>
                    <a-col :md="12" :sm="24">
                      <a-form-model-item>
                        <table-ellipsis :text="$store.getters.getDictCodeObj('saleAreaDictCode')[formData.testCarApplyFormVO.saleArea] || '-'"></table-ellipsis>
                      </a-form-model-item></a-col>
                  </a-row>
                </a-col>
           </a-row>
        </a-form-model-item>
    <a-form-model-item>
      <a-row >
        <!-- 公告型号 -->
        <a-col :md="8" :sm="8">
          <a-row>
            <a-col :md="9" :sm="24">
              <a-form-model-item class="deepClass">
                公告型号
              </a-form-model-item>
            </a-col>
            <a-col :md="12" :sm="24">
              <a-form-model-item>
                <table-ellipsis :text="formData.testCarApplyFormVO.publishCode || '-'"></table-ellipsis>
              </a-form-model-item></a-col>
          </a-row>
        </a-col>
      </a-row>

    </a-form-model-item>

    <a-form-model-item label="车辆信息" class="customFormModelItem2"> </a-form-model-item>
    <!-- 车辆信息 -->
    <a-form-model-item>
          <a-row >
            <!-- VIN -->
            <a-col :md="8" :sm="8">
              <a-row>
                <a-col :md="9" :sm="24">
                  <a-form-model-item class="deepClass">
                    VIN
                  </a-form-model-item>
                </a-col>
                <a-col :md="12" :sm="24">
                  <a-form-model-item>
                    <table-ellipsis :text="formData.testCarApplyFormVO.vin || '-'"></table-ellipsis>
                  </a-form-model-item></a-col>
              </a-row>
            </a-col>
            <!-- 车辆类型 -->
            <a-col :md="8" :sm="8">
              <a-row>
                <a-col :md="9" :sm="24">
                  <a-form-model-item class="deepClass">
                    车辆类型
                  </a-form-model-item>
                </a-col>
                <a-col :md="12" :sm="24">
                  <a-form-model-item>
                    <table-ellipsis :text="formData.testCarApplyFormVO.vehicleType || '-'"></table-ellipsis>
                  </a-form-model-item></a-col>
              </a-row>
            </a-col>
            <!-- 生产工厂 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      生产工厂
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="$store.getters.getDictCodeObj('manufacturerDictCode')[formData.testCarApplyFormVO.manufacturer] || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
          </a-row>
          <a-row >
            <!-- 生产批次 -->
            <a-col :md="8" :sm="8">
              <a-row>
                <a-col :md="9" :sm="24">
                  <a-form-model-item class="deepClass">
                    生产批次
                  </a-form-model-item>
                </a-col>
                <a-col :md="12" :sm="24">
                  <a-form-model-item>
                    <table-ellipsis :text="formData.testCarApplyFormVO.produceBatch || '-'"></table-ellipsis>
                  </a-form-model-item></a-col>
              </a-row>
            </a-col>
            <!-- 生产日期 -->
            <a-col :md="8" :sm="8">
              <a-row>
                <a-col :md="9" :sm="24">
                  <a-form-model-item class="deepClass">
                    生产日期
                  </a-form-model-item>
                </a-col>
                <a-col :md="12" :sm="24">
                  <a-form-model-item>
                    <table-ellipsis :text="formData.testCarApplyFormVO.productionTime || '-'"></table-ellipsis>
                  </a-form-model-item></a-col>
              </a-row>
            </a-col>
            <!-- 生产阶段 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      生产阶段
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.producePhase || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 车身颜色 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      车身颜色
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.color || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 内饰颜色 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      内饰颜色
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.interiorColor || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 座位数 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      座位数
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.seats || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 入库时间 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      入库时间
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="insertTime"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 库位 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      库位
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.locationDesc || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- iccId -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      ICCID
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.iccId || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 主机零件号 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      主机零件号
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.mainframePartCode || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 主机平台 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      主机平台
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.mainframePlatform || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- 主机SN号 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      主机SN号
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.mainframeSn || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- ECC证书 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      ECC证书
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.eccCertificate || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
              <!-- RSA证书SN号 -->
              <a-col :md="8" :sm="8">
                <a-row>
                  <a-col :md="9" :sm="24">
                    <a-form-model-item class="deepClass">
                      RSA证书SN号
                    </a-form-model-item>
                  </a-col>
                  <a-col :md="12" :sm="24">
                    <a-form-model-item>
                      <table-ellipsis :text="formData.testCarApplyFormVO.rsaSn || '-'"></table-ellipsis>
                    </a-form-model-item></a-col>
                </a-row>
              </a-col>
          </a-row>
        </a-form-model-item>
  </a-form-model>
</template>
<script>
import { downloadBlobFile } from '@/utils/functions'
import ViewReleaseNote from '@/views/components/ViewReleaseNote'
import QuestionMarkTip from '@/views/components/QuestionMarkTip'
import TableEllipsis from '@/components/Ellipsis/TableEllipsis'
import { ecuTableColumns, yesOrNoEnumArr, yesOrNoEnumArr12 } from '../config/list'
import TaskGcyUploadInfo from '@/views/task/components/taskGcyUploadInfo'
import moment from 'moment'
export default {
  components: { TableEllipsis, QuestionMarkTip, ViewReleaseNote,TaskGcyUploadInfo },
  data () {
    return {
      formLayout: 'horizontal',
      showEdit: false,
      columns: ecuTableColumns,
      showEcuTable: true,
      yesOrNoEnumArr,
      formData: {
        task: {},
        strategyVo: {},
        taskGcyExtVo: {},
        conditionStrategyVo: {
          items: []
        },
        instanceResponse: {
          tasks: [],
          viewer: {
            finishedTaskSet: [],
            finishedSequenceFlowSet: [],
            unfinishedTaskSet: [],
            rejectedTaskSet: []
          }
        },
        taskUpgradeStatisticsVo: {},
        vehicleVersionVo: {
          model: {},
          ecuVersions: [{
            ecu: {},
            version: {} }]
        },
        taskGcyExtVo: {},
        applyFormVO: {},
        testCarApplyFormVO:{}
      },
      releaseNotes: null,
      ecuVersionQueruId: null,
      yesOrNoEnumArr12,
      formDataItems: {},
      applyUserName:null
    }
  },
  created () {
    this.$store.dispatch('getSaleAreaDictCodeData');
    this.$store.dispatch('getCompanyDictCodeData');
  },
  mounted () {
    // 获取申请内容详情
    this.getApplicationDetail()
    this.getTaskConditionStategy()
    this.$store.dispatch('getGcyOtaUpdateScopeDictCodeData')
    this.$store.dispatch('getGcyOtaSupplierVerifyResultDictCodeData')
    this.$store.dispatch('getFactoryChannelDictCodeData')
    this.$store.dispatch('getManufacturerDictCodeData')
  },
  computed:{
    factoryChannelObj () {
      return this.$store.getters.getDictCodeObj('factoryChannelDictCode')
    },
    slienceUpgradeTypeObj () {
      return this.$store.getters.getTaskDictCodeObj('slienceUpgradeType')
    },
    forceUpgradeTypeObj () {
      return this.$store.getters.getTaskDictCodeObj('forceUpgradeType')
    },
    insertTime () {
      return this.formData.testCarApplyFormVO.insertTime ? moment(this.formData.testCarApplyFormVO.insertTime).format('YYYY-MM-DD') : '-'
    }
  },
  methods: {
    getTaskConditionStategy(){
      this.$api.getTaskConditionById(this.$route.query.key).then(res => {
        if (res.data.length > 0) {
          const obj = {}
          res.data.forEach(item => {
            obj[item.code] = item.value
          })
          this.formDataItems = obj
        }
      })
    },
    // 导出任务车辆
    exportTaskVehicle () {
      this.$api.exportTaskCars({ taskId: this.$route.query.key, type: 1 })
        .then((res) => {
          downloadBlobFile(res, this.$t('export') + this.$t('vehicle') + '.xlsx')
        })
        .finally(() => {
          this.exporting = false
        })
    },
    // 格式化有效时间
    formatExpirationDate (time) {
      return Math.ceil(time / 1000 / 24 / 60 / 60)
    },
    // 导出追加车辆
    exportImportVehicle () {
        this.$api.exportImportVehicle({ taskId: this.$route.query.key, instanceId: this.$route.query.id, type: 1 })
          .then((res) => {
            downloadBlobFile(res, this.$t('export') + this.$t('vehicle') + '.xlsx')
          })
          .finally(() => {
            this.exporting = false
          })
      },
    // 点击查看发布说明
    showRelease (version) {
      this.$api.versionInfor({ id: version.versionId }).then(response => {
        this.releaseNotes = {
          description: response.data.description,
          functionAddition: response.data.functionAddition,
          functionOptimization: response.data.functionOptimization,
          acknowledgements: response.data.acknowledgements
        }
      }).finally(
        this.$refs.releaseNote.visible = true
      )
    },
    // tooltip弹出防止错位
    getPopupContainerColumn () {
      return document.body
    },
    // 根据申请人id获取名称
    getUserName(){
      this.$api.getUserInfo({
        id:this.formData.taskGcyExtVo.applyUserId
      }).then((res)=>{
        this.applyUserName=res.data.name
      })
    },
    // 获取申请内容详情
    getApplicationDetail () {
      this.$api.getCommonApplyDetail(this.$route.query.id).then((res) => {
        this.formData = res.data
      })
    },
  }
}
</script>
<style lang="less" scoped>
::v-deep .ant-form-item{
margin-bottom: 8px ;
}
::v-deep .deepClass{
    font-weight: 600;
    margin-right: 38px;
    text-align: right;

}
::v-deep .ant-form-item-label {
    font-weight: 600;
    margin-right: 12px;
}
  .customFormModelItem2 {
      ::v-deep .ant-form-item-label {
        &::before {
          display: inline-block;
          content: '';
          width: 6px;
          background-color: rgba(67, 136, 166, 1);
          height: 14px;
          vertical-align: middle;
          margin-right: 3px;
        }
      }
    }
</style>
